package com.example.demo.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.demo.common.Result;
import com.example.demo.entity.TComment;
import com.example.demo.service.impl.TCommentServiceImpl;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wzz
 * @since 2023-09-24
 */
@RestController
@RequestMapping("/comment")
public class TCommentController {
    @Resource
    private TCommentServiceImpl tCommentService;

    @GetMapping("/tree/{articleId}")
    public Result findTree(@PathVariable Integer articleId){
//        QueryWrapper<TComment> queryWrapper  = new QueryWrapper<>();
//        queryWrapper.eq("article_id",articleId);
//        List<TComment> comments = tCommentService.list(queryWrapper);
        tCommentService.findTree(articleId);
        return Result.success(tCommentService.findTree(articleId));
    }
}
